package com.hsc.www.selfLock;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

public class LogMethodInterceptor implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {

        System.out.println("拦截前");
        Object object = invocation.proceed();
        System.out.println("拦截后");
        return object;




//        //获取目标类
//        Class<?> targetClass = (invocation.getThis() != null ? AopUtils.getTargetClass(invocation.getThis()) : null);
//        //获取指定方法
//        Method specificMethod = ClassUtils.getMostSpecificMethod(invocation.getMethod(), targetClass);
//        //获取真正执行的方法,可能存在桥接方法
//        final Method userDeclaredMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
//        //获取方法上注解
//        Async async = AnnotatedElementUtils.findMergedAnnotation(userDeclaredMethod, Async.class);
//        if (async == null) {
//            async = AnnotatedElementUtils.findMergedAnnotation(userDeclaredMethod.getDeclaringClass(), Async.class);
//        }
//        //获取返回类型
//        Class<?> returnType = invocation.getMethod().getReturnType();
    }
}